package com.pureut.quality.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pureut.quality.domain.AuditNonconformity;
import com.pureut.quality.domain.AuditSummaryDetails;
import com.pureut.quality.domain.ConverterManagement;
import com.pureut.quality.domain.dto.AuditSummaryDetailsDto;
import com.pureut.quality.domain.vo.AuditSummaryDetailsVo;
import com.pureut.quality.domain.vo.SubmitVo;
import com.pureut.quality.mapper.AuditSummaryDetailsMapper;
import com.pureut.quality.mapper.ConverterManagementMapper;
import com.pureut.quality.service.ConverterManagementService;
import com.pureut.quality.service.IAuditSummaryDetailsService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * 审核总结报告明细Service业务层处理
 *
 * @author ruoyi
 * @date 2025-04-09
 */
@Service
public class AuditSummaryDetailsServiceImpl extends ServiceImpl<AuditSummaryDetailsMapper, AuditSummaryDetails> implements IAuditSummaryDetailsService {

    @Autowired
    private AuditSummaryDetailsMapper auditSummaryDetailsMapper;

    /**
     * 查询审核总结报告明细
     *
     * @param id 审核总结报告明细主键
     * @return 审核总结报告明细
     */
    @Override
    public AuditSummaryDetailsDto selectAuditSummaryDetailsById(Long id)
    {
        return auditSummaryDetailsMapper.selectAuditSummaryDetailsById(id);
    }

    /**
     * 查询审核总结报告明细列表
     *
     * @param auditSummaryDetails 审核总结报告明细
     * @return 审核总结报告明细
     */
    @Override
    public List<AuditSummaryDetailsDto> selectAuditSummaryDetailsList(AuditSummaryDetailsVo auditSummaryDetails)
    {
        return auditSummaryDetailsMapper.selectAuditSummaryDetailsList(auditSummaryDetails);
    }


    /**
     * 修改审核总结报告明细
     *
     * @param auditSummaryDetails 审核总结报告明细
     * @return 结果
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public boolean updateAuditSummaryDetails(AuditSummaryDetailsVo auditSummaryDetails)
    {

        AuditSummaryDetails entity = new AuditSummaryDetails();
        if (auditSummaryDetails.getScore() == null){
            auditSummaryDetails.setScore(new BigDecimal("0"));

        }
        BeanUtils.copyProperties(auditSummaryDetails, entity);
        entity.setId(auditSummaryDetails.getId());
        return updateById(entity);
    }

}
